package FIT::Fixture::Reference;

use FIT::Class;
use FIT::TypeAdapter; # for InputFile and TestResult types
use FIT::Document::Transformer;
use aliased 'FIT::Runner';

extends 'FIT::Fixture::Column';

has location => (is => 'rw', isa => 'InputFile');
has result   => (isa => 'TestResult');

# add one expected column called result- all child tests are expected to be OK
before do_rows =>
    sub { transform { AddColumns columns are [['result?' => 'OK']] } shift->table };

sub compute_result {
    my $context   = $self->context;
    my $exit_code = Runner->new(
        parent  => $context->runner,
        options => {
            in  => $context->make_in_file(  $self->location )->name,
            out => $context->make_out_file( $self->location )->name,
        },
    )->run;
    return $exit_code? 'FAIL': 'OK';
}
